<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:p="http://primefaces.org/ui"
	template="/templates/layout.xhtml">
		
	<ui:define name="head">	</ui:define>

	<ui:define name="ptitle">合同查询</ui:define>
	
	<ui:define name="pcontent">
	
	<h:form id="frm6"> 
		<h:panelGrid columns="12" cellspacing="10">	
            <p:commandButton value="查询合同"	icon="ui-icon-search"  
				action="#{contractQueryMB.queryAction}"  update=":frm7 :frm8">
			</p:commandButton>			
			<p:outputLabel value="合同编号" />
			<p:inputText  value="#{contractQueryMB.io.id}" />
			<p:outputLabel value="合同名称" />
			<p:inputText value="#{contractQueryMB.io.name}" />
			<p:outputLabel value="项目经理" />
			<p:inputText value="#{contractQueryMB.io.pm}" />
 			<p:outputLabel value="施工方" />
			<p:inputText value="#{contractQueryMB.io.construct}" />
			<p:outputLabel value="合同状态" />
			<p:selectOneMenu value="#{contractQueryMB.io.status}" effect="fold" style="width:80%;"> 
				<f:selectItems value="#{contractQueryMB.itemsContractStatus}" />
			</p:selectOneMenu>					
	
		</h:panelGrid>
	</h:form>

	<h:form id="frm7">
		<p:growl id="msgs7" showDetail="true" />
		<p:panel id="contPanel" header="合同信息" style="margin-bottom:5px">
			
			<p:dataTable id="rdt" value="#{contractQueryMB.voc}"  style="margin-bottom:5px"
				var="row"  rowIndexVar="rowNum" 
				scrollable="true" scrollWidth="98%"  sortBy="#{row.createTime}" 
				paginator="true" paginatorPosition="bottom" rows="8"  emptyMessage="没有记录" 
				paginatorTemplate="{Exporters}  {CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} "
                selectionMode="single" selection="#{contractQueryMB.selectedContract}" rowKey="#{row.id}" >
                
				<p:ajax event="rowSelect" listener="#{contractQueryMB.onRowSelected}" update=":frm8" />		
				<f:facet name="{Exporters}">
		            <h:commandLink title="导出XLS">
		                <p:graphicImage name="/images/xls.png" width="16" height="16"/>
		                <p:dataExporter type="xls" target="rdt" fileName="contracts" />
		            </h:commandLink>		 
		        </f:facet> 
		        				
				<p:column headerText="No."  width="20"  exportable="false" >
					#{rowNum+1}
				</p:column>
				<p:column headerText="合同编号"  width="100" sortBy="#{row.id}">
					<h:outputText value="#{row.id}" />
				</p:column>
				<p:column headerText="合同名称" width="100" sortBy="#{row.name}" >
					<h:outputText value="#{row.name}" />
				</p:column>
				<p:column headerText="合同日期" width="60" sortBy="#{row.signDate}" >
					<h:outputText value="#{row.signDate}" >
						<f:convertDateTime pattern="yyyy-MM-dd" timeZone="GMT+8" /> 
					</h:outputText>
				</p:column>
				<p:column headerText="客户" width="100" sortBy="#{row.custName}">
					<h:outputText value="#{row.custName}" />
				</p:column>
				<p:column headerText="城市" width="40" sortBy="#{row.custCity}">
					<h:outputText value="#{row.custCity}" />
				</p:column>
				<p:column headerText="项目经理" width="40" >
					<h:outputText value="#{row.pm}" />
				</p:column>
				<p:column headerText="施工方" width="90" >
					<h:outputText value="#{row.construct}" />
				</p:column>
				<p:column headerText="合同状态" width="40" >
					<p:selectOneMenu value="#{row.status}"  disabled="true"	>
						<f:selectItems value="#{contractQueryMB.itemsContractStatus}" />
					</p:selectOneMenu>				
				</p:column>
				<p:column headerText="合同金额" width="60" >
					<h:outputText value="#{row.price}" />
				</p:column>
				<p:column headerText="备注" width="100" >
					<h:outputText value="#{row.remarks}" />
				</p:column>
				<p:column headerText="录入时间" width="100" sortBy="#{row.createTime}" >
					<h:outputText value="#{row.createTime}" >
						<f:convertDateTime pattern="yyyy-MM-dd HH:mm:ss" timeZone="GMT+8" /> 
					</h:outputText>
				</p:column>    
			</p:dataTable>
						
		</p:panel>
		
	</h:form>
	<h:form id="frm8">
	<p:growl id="msgs8" showDetail="true" />
	<p:panel id="contProdPanel" header="合同产品信息" style="margin-bottom:5px">
		
		<p:dataTable id="dtContProd" value="#{contractQueryMB.vod}"  var="srow"  rowIndexVar="rowNum"
			style="margin-bottom:5px"
			scrollable="true" scrollWidth="98%" 
			paginator="true" paginatorPosition="bottom" rows="8"  emptyMessage="没有记录" 
			paginatorTemplate="{Exporters}  {CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} " >
			
			<f:facet name="{Exporters}">
	            <h:commandLink title="导出XLS">
	                <p:graphicImage name="/images/xls.png" width="16" height="16"/>
	                <p:dataExporter type="xls" target="dtContProd" fileName="contProds" />
	            </h:commandLink>		 
	        </f:facet> 
		                       
			<p:column headerText="No."  width="20"  exportable="false">
				#{rowNum+1}
			</p:column>
			<p:column headerText="安装区域" width="100" >
				<h:outputText value="#{srow.area}" />
			</p:column>
			<p:column headerText="物料编号" width="100" >
				<h:outputText value="#{srow.bmeMaterial.id}" />
			</p:column>
			<p:column headerText="物料名称" width="100" >
				<h:outputText value="#{srow.bmeMaterial.mdesc}" />
			</p:column>
			<p:column headerText="数量" width="100" >
				<h:outputText value="#{srow.quantity}" />			
			</p:column>
			<p:column headerText="单价" width="100" >
				<h:outputText value="#{srow.price}" />
			</p:column>
			<p:column headerText="金额" width="100" >
				<h:outputText value="#{srow.amount}" />
			</p:column>
			<p:column headerText="备注" width="100" >
				<h:outputText value="#{srow.remarks}" />
			</p:column>
			<p:column headerText="出库数量" width="100" >
				<h:outputText value="#{srow.saleQuantity}" />
			</p:column>
			<p:column headerText="出库比率" width="100" >
				<h:outputText value="#{srow.saleRate}" />
			</p:column>				
			<p:column headerText="已开票额" width="100" >
				<h:outputText value="" />
			</p:column>
			<p:column headerText="已付款额" width="100" >
				<h:outputText value="" />
			</p:column>
			<p:column headerText="付款比例" width="100" >
				<h:outputText value="" />
			</p:column>
			<p:column headerText="未付款额" width="100" >
				<h:outputText value="" />
			</p:column>
			<p:column headerText="可请款额" width="100" >
				<h:outputText value="" />
			</p:column>
			
		</p:dataTable>
						
	</p:panel>
	<p:panel id="contPurchPanel" header="合同采购信息" style="margin-bottom:5px">
		
		<p:dataTable id="dtContPurch"  value="#{contractQueryMB.vop}"  var="prow"  rowIndexVar="prowNum"
			style="margin-bottom:5px"
			scrollable="true" scrollWidth="98%" 
			paginator="true" paginatorPosition="bottom" rows="8"  emptyMessage="没有记录" 
 			paginatorTemplate="{Exporters}  {CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} " >
			
			<f:facet name="{Exporters}">
	            <h:commandLink title="导出XLS">
	                <p:graphicImage name="/images/xls.png" width="16" height="16"/>
	                <p:dataExporter type="xls" target="dtContPurch" fileName="contPurches" />
	            </h:commandLink>		 
	        </f:facet>               
			<p:column headerText="No."  width="20"  exportable="false">
				#{prowNum+1}
			</p:column>
			<p:column headerText="物料编号" width="100" >
				<h:outputText value="#{prow.bmeMaterial.id}" />
			</p:column>
			<p:column headerText="物料名称" width="100" >
				<h:outputText value="#{prow.bmeMaterial.mdesc}" />
			</p:column>
			<p:column headerText="数量" width="100" >
				<h:outputText value="#{prow.quantity}" />			
			</p:column>
			<p:column headerText="单价" width="100" >
				<h:outputText value="#{prow.price}" />
			</p:column>
			<p:column headerText="金额" width="100" >
				<h:outputText value="#{prow.amount}" />
			</p:column>
			<p:column headerText="备注" width="100" >
				<h:outputText value="#{prow.remarks}" />
			</p:column>
			<p:column headerText="已下单量" width="100" >
				<h:outputText value="#{prow.qtyOrdered}" />
			</p:column>
			<p:column headerText="已发货量" width="100" >
				<h:outputText value="#{prow.qtyShipped}" />
			</p:column>
			<p:column headerText="已接收量" width="100" >
				<h:outputText value="#{prow.qtyAccepted}" />
			</p:column>				
			<p:column headerText="在途量" width="100" >
				<h:outputText value="#{prow.qtyShipped - prow.qtyAccepted}" />
			</p:column>
			
		</p:dataTable>
						
	</p:panel>	
	</h:form>
	
	</ui:define>
</ui:composition>
